<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>变量提升带来的影响</title>
  </head>
  <body>
    <script>
      function print() {
        if (true) {
          console.log(a);    //结果：不报错，打印undefined
        }
        var a = "hello world!";
      }
      print();
    </script>
  </body>
</html>
